<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上课笔记</title>
    <!-- 引入 Font Awesome 字体图标库 -->
    <link rel="stylesheet" href="../../static/css/all.min.css">
    <!-- 引入 Quill 富文本编辑器样式和脚本（CDN 方式） -->
    <script src="../../static/js/quill.js"></script>
    <link href="../../static/css/quill.snow.css" rel="stylesheet">
    <!-- 引入 jQuery -->
<!--    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>-->

    <script src="../../static/js/jquery.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../static/js/class_note.js"></script>

    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --border-radius: 8px;
            --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            --border-color: #e0e0e0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', sans-serif;
            background-color: #f5f7fa;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
            overflow: hidden;
        }

        /* 顶部操作栏 */
        .toolbar {
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .search-box {
            flex: 1;
            max-width: 500px;
            margin-left: 20px;
            position: relative;
        }

        .search-box input {
            width: 100%;
            padding: 10px 15px 10px 40px;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            font-size: 14px;
        }

        .search-box i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #adb5bd;
        }

        .search-btn {
            padding: 10px 16px;
            margin-left: 10px;
            border: none;
            border-radius: var(--border-radius);
            background-color: var(--primary-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
        }

        .btn {
            padding: 10px 16px;
            border: none;
            border-radius: var(--border-radius);
            background-color: var(--primary-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
        }

        .btn i, .search-btn i {
            margin-right: 8px;
        }

        /* 笔记表格 */
        .notes-table {
            width: 100%;
            border-collapse: collapse;
        }

        .notes-table th, .notes-table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
        }

        .notes-table th {
            background-color: var(--primary-color);
            color: white;
        }

        /* 操作按钮 */
        .action-btn {
            padding: 6px 10px;
            margin-right: 5px;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            background: none;
            cursor: pointer;
        }

        /* 弹层样式 */
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .modal-content {
            background-color: white;
            padding: 25px;
            border-radius: var(--border-radius);
            width: 800px;
            max-height: 90vh;
            overflow-y: auto;
            position: relative;
        }

        .modal-close {
            position: absolute;
            top: 15px;
            right: 20px;
            font-size: 24px;
            cursor: pointer;
            color: #999;
        }

        .modal h3 {
            margin-bottom: 20px;
            color: #2c3e50;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 8px;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
        }

        /* Quill 编辑器容器样式 */
        .quill-container {
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            min-height: 300px;
        }

        .btn-group {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 20px;
        }

        .btn-secondary {
            background-color: #ecf0f1;
            color: #7f8c8d;
        }

        /* 分页器样式 */
        .pagination-container {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: 20px;
            background: white;
            border-top: 1px solid var(--border-color);
            gap: 10px;
        }

        .pagination-controls {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .page-btn {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background: none;
            cursor: pointer;
            transition: all 0.2s;
        }

        .page-btn:hover {
            border-color: var(--primary-color);
            color: var(--primary-color);
        }

        .page-btn.active {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
            color: white;
        }

        .page-btn.disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .page-input {
            width: 60px;
            height: 36px;
            text-align: center;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            margin: 0 10px;
        }

        .page-size-selector {
            margin-left: 10px;
        }

        .page-size-select {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 3px;
            background: #fff;
            cursor: pointer;
            outline: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 8px center;
            background-size: 16px;
            padding-right: 28px;
        }

        .change {
            width: 50px;
        }

        /* 操作按钮基础样式（保留原有功能，新增交互逻辑） */
        .action-btn {
            padding: 6px 10px;
            margin-right: 5px;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            background: none;
            cursor: pointer;
            /* 让动画更丝滑 */
            transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        /* 图标与文字间距 */
        .action-btn i {
            margin-right: 4px;
            font-size: 14px;
        }

        /* 鼠标悬浮：渐变背景+阴影 */
        .action-btn:hover {
            /* 渐变背景（可根据主题色调整） */
            background: linear-gradient(120deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            border-color: transparent; /* 隐藏原边框 */
            color: #fff; /* 文字变白 */
            box-shadow: 0 4px 12px rgba(67, 97, 238, 0.2); /* 淡蓝色阴影 */
            transform: translateY(-1px); /* 轻微上移 */
        }

        /* 点击按压效果：缩小+位移 */
        .action-btn:active {
            transform: translateY(1px) scale(0.98); /* 下移+缩小 */
            box-shadow: none; /* 隐藏阴影 */
        }

        /* 不同按钮可定制颜色（如删除按钮变红） */
        .action-btn.delete-btn {
            border-color: #ff4757; /* 初始边框色 */
        }
        .action-btn.delete-btn:hover {
            background: linear-gradient(120deg, #ff4757 0%, #ff6b81 100%);
            box-shadow: 0 4px 12px rgba(255, 71, 87, 0.2);
        }

        /* 生成试卷按钮（可单独改色） */
        .action-btn.exam-btn {
            border-color: #2ed573; /* 初始边框色 */
        }
        .action-btn.exam-btn:hover {
            background: linear-gradient(120deg, #2ed573 0%, #7bed9f 100%);
            box-shadow: 0 4px 12px rgba(46, 213, 115, 0.2);
        }
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        /* 正确提示框样式 */
        .alert-success {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 15px 20px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            max-width: 80%;
            animation: slideIn 0.3s ease-out forwards;
        }
        .alert-danger {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 15px 20px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            border: 1px solid #c3e6cb;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            max-width: 80%;
            animation: slideIn 0.3s ease-out forwards;
        }
        .alert-success i {
            margin-right: 10px;
            font-size: 18px;
        }

        .alert-close {
            margin-left: 15px;
            background: none;
            border: none;
            color: inherit;
            font-size: 20px;
            cursor: pointer;
            padding: 0 0 0 10px;
            line-height: 1;
        }

        /* 动画效果 */
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translate(-50%, -30px);
            }
            to {
                opacity: 1;
                transform: translate(-50%, 0);
            }
        }

        @keyframes slideOut {
            from {
                opacity: 1;
                transform: translate(-50%, 0);
            }
            to {
                opacity: 0;
                transform: translate(-50%, -30px);
            }
        }
        .alert {
            padding: 15px;
            margin-bottom: 20px;
            border: 1px solid transparent;
            border-radius: 4px;
            display: none; /* 默认隐藏，通过JS控制显示 */
        }

        .alert-danger {
            color: #a94442;
            background-color: #f2dede;
            border-color: #ebccd1;
        }

        .alert i.fas {
            margin-right: 10px;
        }

        .errorMessage {
            font-weight: bold;
        }

        /* 如果需要动画效果可以添加 */
        .alert.show {
            display: block;
            animation: fadeIn 0.3s;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        .confirmModal{
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .modal-content {
            background-color: white;
            padding: 25px;
            border-radius: 8px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            width: 500px;
            position: relative;
            animation: fadeIn 0.3s;
        }
        .close-btn {
            position: absolute;
            top: 15px;
            right: 20px;
            font-size: 24px;
            color: #999;
            cursor: pointer;
            transition: color 0.2s;
        }

        .close-btn:hover {
            color: #666;
        }

    </style>
</head>
<body>
<div class="alert alert-danger" style="display: none;">
    <i class="fas fa-exclamation-circle"></i>
    <span id="error-message" class="errorMessage">试卷生成失败</span>
</div>
<!-- 正确提示框 -->
<div class="alert alert-success" id="success-alert" style="display: none;">
    <i class="fas fa-check-circle"></i>
    <span id="success-message">试卷已成功生成</span>
    <button class="alert-close">&times;</button>
</div>
<div class="container">
    <!-- 顶部操作栏 -->
    <div class="toolbar">
        <button class="btn" id="addNoteBtn">
            <i class="fas fa-plus"></i> 添加笔记
        </button>
<!--        <div class="search-box">-->
<!--            <i class="fas fa-search"></i>-->
<!--            <input type="text" placeholder="请输入笔记名称..." class="search-notes">-->
<!--        </div>-->
<!--        <button class="btn search-btn" id="searchBtn">-->
<!--            <i class="fas fa-search"></i> 搜索-->
<!--        </button>-->
    </div>

    <!-- 笔记表格 -->
    <table class="notes-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>笔记名称</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="tbody" id="notesTableBody">
        <!-- 示例数据 -->
        <tr>
            <td>1</td>
            <td>数学函数笔记</td>
            <td>
                <button class="action-btn edit-btn" data-id="1">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="action-btn delete-btn" data-id="1">
                    <i class="fas fa-trash"></i> 删除
                </button>
                <button class="action-btn exam-btn" data-id="1">
                    <i class="fas fa-file-alt"></i> 生成试卷
                </button>
            </td>
        </tr>
        <tr>
            <td>2</td>
            <td>英语语法笔记</td>
            <td>
                <button class="action-btn edit-btn" data-id="2">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="action-btn delete-btn" data-id="2">
                    <i class="fas fa-trash"></i> 删除
                </button>
                <button class="action-btn exam-btn" data-id="2">
                    <i class="fas fa-file-alt"></i> 生成试卷
                </button>
            </td>
        </tr>
        <tr>
            <td>3</td>
            <td>物理力学笔记</td>
            <td>
                <button class="action-btn edit-btn" data-id="3">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="action-btn delete-btn" data-id="3">
                    <i class="fas fa-trash"></i> 删除
                </button>
                <button class="action-btn exam-btn" data-id="3">
                    <i class="fas fa-file-alt"></i> 生成试卷
                </button>
            </td>
        </tr>
        <tr>
            <td>4</td>
            <td>化学元素笔记</td>
            <td>
                <button class="action-btn edit-btn" data-id="4">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="action-btn delete-btn" data-id="4">
                    <i class="fas fa-trash"></i> 删除
                </button>
                <button class="action-btn exam-btn" data-id="4">
                    <i class="fas fa-file-alt"></i> 生成试卷
                </button>
            </td>
        </tr>
        <tr>
            <td>5</td>
            <td>生物细胞笔记</td>
            <td>
                <button class="action-btn edit-btn" data-id="5">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="action-btn delete-btn" data-id="5">
                    <i class="fas fa-trash"></i> 删除
                </button>
                <button class="action-btn exam-btn" data-id="5">
                    <i class="fas fa-file-alt"></i> 生成试卷
                </button>
            </td>
        </tr>
        </tbody>
    </table>

    <!-- 分页器 -->
    <div class="pagination-container">
        <div class="pagination-controls">
            <button class="page-btn first">
                <i class="fas fa-angle-double-left"></i>
            </button>
            <button class="page-btn front">
                <i class="fas fa-angle-left"></i>
            </button>
            <div class="page-number" style="display: flex">
                <button class="page-btn active">1</button>
                <button class="page-btn">2</button>
                <button class="page-btn">3</button>
                <button class="page-btn">4</button>
                <button class="page-btn">5</button>
                <span>...</span>
                <button class="page-btn">10</button>
            </div>
            <button class="page-btn next">
                <i class="fas fa-angle-right"></i>
            </button>
            <button class="page-btn end">
                <i class="fas fa-angle-double-right"></i>
            </button>
        </div>
        <div class="page-size-selector">
            <select class="page-size-select">
                <option value="5">5条/页</option>
                <option value="10">10条/页</option>
                <option value="20">20条/页</option>
                <option value="50">50条/页</option>
            </select>
        </div>
        <input type="number" class="page-input" placeholder="页码" min="1" step="1">
        <button class="page-btn change">跳转</button>
    </div>
</div>

<!-- 添加笔记弹层 -->
<div class="modal" id="addNoteModal">
    <div class="modal-content">
        <span class="modal-close" id="closeAddModal">&times;</span>
        <h3>添加笔记</h3>
        <form id="addNoteForm">
            <div class="form-group">
                <label for="noteTitle">笔记名称</label>
                <input type="text" id="noteTitle" required>
            </div>
            <div class="form-group">
                <label for="addQuill">笔记内容</label>
                <!-- Quill 编辑器容器 -->
                <div class="quill-container" id="addQuill"></div>
            </div>
            <div class="btn-group">
                <button type="button" class="btn btn-secondary" id="cancelAddNote">取消</button>
                <button type="submit" class="btn btn-submit">保存</button>
            </div>
        </form>
    </div>
</div>

<!-- 修改笔记弹层 -->
<div class="modal" id="editNoteModal">
    <div class="modal-content">
        <span class="modal-close" id="closeEditModal">&times;</span>
        <h3>修改笔记</h3>
        <form id="editNoteForm">
            <input type="hidden" id="editNoteId">
            <div class="form-group">
                <label for="editNoteTitle">笔记名称</label>
                <input type="text" id="editNoteTitle" required>
            </div>
            <div class="form-group">
                <label for="editQuill">笔记内容</label>
                <!-- Quill 编辑器容器 -->
                <div class="quill-container" id="editQuill"></div>
            </div>
            <div class="btn-group">
                <button type="button" class="btn btn-secondary" id="cancelEditNote">取消</button>
                <button type="submit" class="btn">保存</button>
            </div>
        </form>
    </div>
</div>
<div class="confirmModal" id="confirmModal">
    <div class="modal-content" style="width: 400px;">
        <span class="close-btn" id="closeConfirmModal">&times;</span>
        <h3 id="confirmTitle">是否要删除该教案？</h3>
        <div class="confirm-content" id="confirmContent" style="margin-bottom: 20px;">
            <!-- 提示内容将通过JS动态加载 -->
        </div>
        <div class="confirm-footer" style="display: flex; justify-content: flex-end; gap: 10px;">
            <button class="btn btn-primary" id="confirmYes">是</button>
            <button class="btn btn-cancel" id="confirmNo">否</button>
        </div>
    </div>
</div>
<div id="compact-loader" style="
  position: fixed;
  top:50%;
  left:50%;
  right: 20px;
  width: 240px;
  padding: 12px;
  background: rgba(0,0,0,0.85);
  border-radius: 8px;
  display: none;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.3s;
  translate: -120px 0px;
  color: white;
  font-family: sans-serif;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
">
    <div class="spinner" style="
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
  "></div>
    <span class="text">正在根据笔记生成试卷</span>
</div>
</body>
</html>
